//
//  vistorViewController.swift
//  weibo001
//
//  Created by ios on 15/11/4.
//  Copyright © 2015年 ios. All rights reserved.
//

import UIKit

class vistorViewController: UITableViewController {

    private var UserLogin =  UserAccountViewModel.sharedUserAccount.UserLogin
    
    var vistorView : VistorView?
    
    override func loadView() {
        UserLogin ?  super.loadView() : setupVistorView()
        
    }
    
    
    private func setupVistorView() {
        
        vistorView = VistorView()
        
        view = vistorView
        
      //  view.backgroundColor = UIColor.redColor()
        
        //添加监听方法
        
        vistorView?.registerButton.addTarget(self, action: "visitorViewDidRegister", forControlEvents: UIControlEvents.TouchUpInside)
        vistorView?.loginButton.addTarget(self, action: "visitorViewDidLogin", forControlEvents: UIControlEvents.TouchUpInside)
        
        // 设置导航控制器item
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidLogin")
        
        
    }
    
}

extension vistorViewController {

    func visitorViewDidRegister() {
    print("注册")
    
    }
    func visitorViewDidLogin() {
        
        let vc = OAuthController()
        
        let nav = UINavigationController(rootViewController: vc)
        
        presentViewController(nav, animated: true, completion: nil)
        
        
        
    }

}












